<template>
  <RouterView />
</template>
<script setup>
import { onMounted, onUnmounted } from 'vue';
import { useUserStore } from '@/stores/user';
import { useWebSocketStore } from '@/stores/websocket';

const userStore = useUserStore();
const webSocketStore = useWebSocketStore();

onMounted(() => {
  if (userStore.token) {
    webSocketStore.initWebSocket(userStore.token);
  }
});

onUnmounted(() => {
  webSocketStore.closeWebSocket();
});
</script>